<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="/static/js/head.js"></script>
<link rel="stylesheet" type="text/css" href="/static/css/contractCreate.css"/>
</head> 
<body>
<div align="center" style="width:100%">
	<fieldset>
		<legend>创建合同</legend>
		<form id="addForm">
		<input id="id" name="id" type="hidden"></input>
			<table class="tableForm">
				<tr>
					<td class="formLeft">合同区域:</td>
					<td class="formRight">
						<input class="easyui-validatebox" name="region" id="region" placeholder="请输入区域，如有多个请用中文逗号隔开" required="required"/>
					</td>
				</tr>
				<tr>
					<td class="formLeft">甲方名称:</td>
					<td class="formRight">
						<select class="easyui-combobox" name="firstPartyName" id="firstPartyName" placeholder="请输入甲方名称" required="required" style="width:263px;">
						    <option value="移动">移动</option>
						    <option value="联通">联通</option>
						    <option value="电信">电信</option>
						    <option value="铁塔">铁塔</option>
						    <option value="省通建">省通建</option>
						    <option value="广电">广电</option>
						    <option value="其他">其他</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="formLeft">中标单位:</td>
					<td class="formRight">
						<input class="easyui-validatebox" name="secondPartyName" id="secondPartyName" placeholder="请输入乙方名称" required="required"/>
					</td>
				</tr>
				<tr>
					<td class="formLeft">合同编号:</td>
					<td class="formRight">
						<input class="easyui-validatebox" name="contractNo" id="contractNo" placeholder="请输入合同编号" required="required"/>
					</td>
				</tr>
				<tr>
					<td class="formLeft">合同名称:</td>
					<td class="formRight">
						<input class="easyui-validatebox" name="contractName" id="contractName" placeholder="请输入合同名称" required="required"/>
					</td>
				</tr>
				<tr>
					<td class="formLeft">合同金额:</td>
					<td class="formRight">
						<input class="easyui-numberbox" data-options="min:0" name="contractAmount" id="contractAmount" placeholder="请输入合同金额 (选填)"  />
					</td>
				</tr>
				<tr>
					<td class="formLeft">签订时间:</td>
					<td class="formRight">
						<input class="easyui-datebox" name="signTime" id="signTime" placeholder="请输入签订时间"/>
					</td>
				</tr>
				<tr>
					<td class="formLeft">开始时间:</td>
					<td class="formRight">
						<input class="easyui-datebox" name="startTime" id="startTime" placeholder="请输入开始时间"/>
					</td>
				</tr>
			</table>
			<div>
				<a id="insert" class="easyui-linkbutton" data-options="iconCls:'icon-ccSearch'">保存</a>
				<a id="resetbtn" style="margin-left:40px" onclick="reset()" class="easyui-linkbutton" data-options="iconCls:'icon-ccReload'">重置</a>
			</div>
		</form>
	</fieldset>
</div>
</body>
</html>
<script>
$(function(){
	$.ajaxSetup({crossDomain: true, xhrFields: {withCredentials: true}});
	//点击事件
	clickFunction();
});
function clickFunction(){
		//重置按钮
		$('#resetbtn').click(function(){
			$('#addForm').form('clear');
		});
		//保存按钮
		$('#insert').click(function(){
			addInfo();
		});
	}
	
		//添加信息
		function addInfo(){
			if($("#addForm").form('validate')){
				$.ajax({
					url:getHost() + '/contract',
					type:'POST',
					data:JSON.stringify({
						region : $("#region").val(),
						firstPartyName : $('#firstPartyName').combobox('getValue'),
						secondPartyName : $("#secondPartyName").val(),
						contractNo : $("#contractNo").val(),
						contractName : $("#contractName").val(),
						signTime : $("#signTime").val(),
						startTime : $("#startTime").val(),
						contractAmount : $("#contractAmount").val(),
					}),
					dataType : "json",
					contentType: 'application/json;charset=UTF-8',
					error : function(XMLHttpRequest, textStatus, errorThrown){
						$.messager.alert("提示","数据操作存在异常!");
					},
					beforeSend: function(xhr) {
		                xhr.withCredentials = true;
		            },
		            crossDomain:true,
					success:function(data){
						if(data.code=="200"&&data.data.item.id>0){
							$.messager.alert("提示","保存成功");
							$('#addForm').form('clear');
						}else{
							$.messager.alert("提示",data.message);
						}
					}
				});
			}
		}
</script>